package com.qf.api.sys.query;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.api.sys.entity.SysLoginLogEntity;
import com.qf.api.sys.mybatis.page.AbstractQuery;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @Author: sin
 * @Date: 2025/5/10 21:56
 * @Description:
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class LoginLogQuery extends AbstractQuery<SysLoginLogEntity> {

    private String username;

    private Integer status;

    @Override
    public QueryWrapper<SysLoginLogEntity> addQueryCondition() {
        QueryWrapper<SysLoginLogEntity> queryWrapper = new QueryWrapper<SysLoginLogEntity>()
            .eq(status != null, "status", status)
            .like(StrUtil.isNotEmpty(username), "username", username);

        addSortCondition(queryWrapper);
        // 可以手动设置  也可以由前端传回  "timeRangeColumn":"loginTime"
        this.timeRangeColumn = "loginTime";
        return queryWrapper;
    }
}
